package http2;

import java.io.IOException;
import java.net.URI;

import jdk.incubator.http.HttpClient;
import jdk.incubator.http.HttpRequest;
import jdk.incubator.http.HttpResponse;

public class Http2Test {

	public static void main(String[] args) throws IOException, InterruptedException {
		
		HttpClient client = HttpClient.newHttpClient();
		 
		HttpRequest req =
		   HttpRequest.newBuilder(URI.create("http://www.baidu.com"))
		              .header("User-Agent","Java")
		              .GET()
		              .build();
		
		HttpResponse<String> resp = client.send(req, HttpResponse.BodyHandler.asString());
		System.out.println(resp.statusCode());
		System.out.println(resp.version().name());
		System.out.println(resp.body().toString()); 
		 
	}
}
